package com.project.isaacwiki.service.impl;

import com.project.isaacwiki.dto.ItemComplete;
import com.project.isaacwiki.dto.ItemMvp;
import com.project.isaacwiki.mapper.MapperQueryItem;
import com.project.isaacwiki.service.ServiceQueryItem;
import com.project.isaacwiki.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServiceQueryItemImpl implements ServiceQueryItem {

    @Autowired
    private MapperQueryItem mapperQueryItem;

    @Override
    public Result queryAllItemMvp() {
        return Result.Success(mapperQueryItem.queryAllItemMvp());
    }

    @Override
    public Result queryItemById(Integer id) {
        ItemComplete itemComplete = new ItemComplete();

        itemComplete.setItem(mapperQueryItem.queryItemById(id));
        itemComplete.setItemsAttributes(mapperQueryItem.queryItemAttributesById(id));
        itemComplete.setSynergies(mapperQueryItem.querySynergyById(id));
        itemComplete.setItemPoolTypes(mapperQueryItem.queryItemPoolTypeById(id));
        itemComplete.setItemImgPath(mapperQueryItem.queryItemImgPathById(id));
        return Result.Success(itemComplete);
    }
    @Override
    public Result queryItemMvpByName(String name) {
        List<ItemMvp> itemMvp = mapperQueryItem.queryItemMvpByName(name);
        return Result.Success(itemMvp);
    }
}
